package com.erlang.spring.controller;

import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * @Description：
 */
public class ClientController {


  @Test
  public void saveAccount() {

    /**
     * Spring-IOC容器：ApplicationContext
     * 构建方式：通过ClassPathXmlApplicationContext加载配置文件
     * 使用bean:getBean
     */
    System.out.println("======ApplicationContext开始创建容器=====");
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bean.xml");
    System.out.println("======ApplicationContext创建容器完成=====");
    applicationContext.getBean("accountDao");

    System.out.println("======分割线==========");

    System.out.println("======BeanFactory开始创建容器=====");
    Resource resource = new ClassPathResource("bean.xml");
    BeanFactory beanFactory = new XmlBeanFactory(resource);
    System.out.println("======BeanFactory创建容器完成=====");
    beanFactory.getBean("accountDao");
  }
}
